package com.api.chatai.exception;

import com.api.chatai.domain.pojo.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@ControllerAdvice
public class GlobalException {

    //    全局异常处理，方法的执行
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e){
        return Result.error("操作出现异常,刷新重试！");
    }



    //    自定义异常处理
    @ExceptionHandler(myException.class)
    @ResponseBody
    public Result error(myException e) {
        return Result.error(e.getMsg());
    }


}